package com.newbee.controller;

import com.newbee.aop.SkipTrace;
import com.newbee.model.TraceNode;
import com.newbee.model.TraceSearchRequest;
import com.newbee.model.TraceSearchResponse;
import com.newbee.model.common.CommonResponse;
import com.newbee.service.TraceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/trace")
@RestController
public class TraceController {

    @Autowired
    private TraceService traceService;

    @GetMapping("/search")
    @SkipTrace
    public CommonResponse<TraceSearchResponse> searchTrace(TraceSearchRequest req) {
        List<TraceNode> traceNodes = traceService.searchTrace(req);
        TraceSearchResponse response = new TraceSearchResponse();
        response.setTraceNodes(traceNodes);
        return CommonResponse.success(response);
    }
}
